<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="949">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
span.s1 {font: 18.0px Helvetica}
span.s2 {color: #1a3794}
span.s3 {color: #5f663a}
span.s4 {color: #0d2ea2}
span.s5 {color: #576a2e}
span.Apple-tab-span {white-space:pre}
</style>
</head>
<body>
<p class="p1"><span class="s1"><b>FMGrainI<span class="Apple-tab-span">	</span></b></span><b><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>granular synthesis with FM grains and user supplied envelopes</b></p>
<p class="p2"><br></p>
<p class="p1"><b><span class="Apple-converted-space"> </span>*ar(trigger, dur, carfreq, modfreq, index, envbuf1, envbuf2, ifac, mul, add)<span class="Apple-converted-space"> </span></b></p>
<p class="p2"><br></p>
<p class="p1"><b><span class="Apple-tab-span">	</span>trigger </b>- a kr or ar trigger to start a new grain. If ar, grains after the start of the synth are sample accurate.</p>
<p class="p1"><span class="Apple-tab-span">	</span>The following args are polled at grain creation time</p>
<p class="p1"><span class="Apple-tab-span">	</span><b>dur</b> - size of the grain.</p>
<p class="p1"><span class="Apple-tab-span">	</span><b>carfreq</b> - the carrier freq of the grain generators internal oscillator</p>
<p class="p1"><span class="Apple-tab-span">	</span><b>modfreq</b> - the modulating freq of the grain generators internal oscillator</p>
<p class="p1"><span class="Apple-tab-span">	</span><b>index - </b>the index of modulation</p>
<p class="p1"><span class="Apple-tab-span">	</span><b>envbuf1 -</b> a buffer with a stored signal to be used for the envelope of the grain</p>
<p class="p1"><span class="Apple-tab-span">	</span><b>envbuf2 -</b> a buffer with a stored signal to be used for the envelope of the grain</p>
<p class="p1"><span class="Apple-tab-span">	</span><b>ifac -</b> an interpolation factor. interpolates between the two envelopes where 0 is all envbuf1, and 1 is all</p>
<p class="p1"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>envbuf2</p>
<p class="p2"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></p>
<p class="p1"><b>Examples:</b></p>
<p class="p3"><br></p>
<p class="p4">s.boot;</p>
<p class="p3"><br></p>
<p class="p4"><span class="s2">SynthDef</span>(<span class="s3">\fm_grain_test</span>, {<span class="s2">arg</span> gate = 1, amp = 1, envbuf1, envbuf2;</p>
<p class="p4"><span class="Apple-tab-span">	</span><span class="s2">Out</span>.ar(0,</p>
<p class="p4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s2">FMGrainI</span>.ar(<span class="s2">Impulse</span>.kr(10), 0.2, <span class="s2">WhiteNoise</span>.kr.range(440, 880), 200,<span class="Apple-converted-space"> </span></p>
<p class="p4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>LFNoise1.kr(1).range(1, 10), envbuf1, envbuf2, MouseX.kr(0, 1),</p>
<p class="p4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s2">EnvGen</span>.kr(</p>
<p class="p4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="s2">Env</span>([0, 1, 0], [1, 1], <span class="s3">\sin</span>, 1),</p>
<p class="p4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>gate,</p>
<p class="p4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>levelScale: amp,</p>
<p class="p4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>doneAction: 2)</p>
<p class="p4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>)</p>
<p class="p4"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>)</p>
<p class="p4"><span class="Apple-tab-span">	</span>}).load(s);</p>
<p class="p3"><span class="Apple-tab-span">	</span></p>
<p class="p4">y = <span class="s4">Env</span>([0, 1, 0], [1, 1], <span class="s5">\sin</span>).asSignal(1024);</p>
<p class="p4">z = <span class="s4">Env</span>([0, 1, 0], [1, 1], [10, -10]).asSignal(1024);</p>
<p class="p4">s.sendMsg(<span class="s5">\b_alloc</span>, b = s.bufferAllocator.alloc(1), 1024, 1, [<span class="s5">\b_setn</span>, b, 0, 1024] ++ y)</p>
<p class="p4">s.sendMsg(<span class="s5">\b_alloc</span>, c = s.bufferAllocator.alloc(1), 1024, 1, [<span class="s5">\b_setn</span>, c, 0, 1024] ++ z)</p>
<p class="p4">s.sendMsg(<span class="s5">\s_new</span>, <span class="s5">\fm_grain_test</span>, a=s.nextNodeID, 0, 1, <span class="s5">\amp</span>, 0.2, <span class="s5">\envbuf1</span>, b, <span class="s5">\envbuf2</span>, c);</p>
<p class="p4">s.sendMsg(<span class="s5">\n_set</span>, a, <span class="s5">\gate</span>, 0);</p>
<p class="p4">s.sendMsg(<span class="s5">\b_free</span>, b);</p>
<p class="p4">s.sendMsg(<span class="s5">\b_free</span>, c);</p>
</body>
</html>
